const filters = {

  year (date) {
    if (date) {
      let dateArry = date.split('-')
      return dateArry[0]
    }
  },
  month (date) {
    if (date) {
      let dateArry = date.split('-')
      return dateArry[1]
    }
  },
  day (date) {
    if (date) {
      let dateArry = date.split('-')
      return dateArry[2]
    }
  },
  week (date) {
    if (date) {
      const weekArray = ['日', '一', '二', '三', '四', '五', '六']
      var format = date.replace(/-/g, '/')
      const week = weekArray[new Date(format).getDay()]
      return `周${week}`
    }
  },
  days (date) {
    if (date[0] && date[1]) {
      const day1 = new Date(date[0].replace(/-/g, '/'))
      const day2 = new Date(date[1].replace(/-/g, '/'))
      return (day2 - day1) / (1000 * 60 * 60 * 24)
    }
  },
  imgUrl (img) {
    return 'https://www.felixmantuoluo.com' + img
  },
  num (val) {
    return val.toFixed(2)
  },
  orderStuts (val) {
    switch (val) {
      case '0':
        return ''
      case '1':
        return '未支付'
      case '2':
        return '已支付'
      case '3':
        return '已取消'
    }
  },
  payWay (val) {
    switch (val) {
      case '0':
        return '会员卡支付'
      case '1':
        return '现金支付'
    }
  }
}
export default filters
